/*
 * Copyright 2018 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.eduhzy.ttw.commonsdk.http;

import com.eduhzy.ttw.commonsdk.entity.AliOrderData;
import com.eduhzy.ttw.commonsdk.entity.ChooseClassData;
import com.eduhzy.ttw.commonsdk.entity.ChooseSubjectData;
import com.eduhzy.ttw.commonsdk.entity.ClassDetailsData;
import com.eduhzy.ttw.commonsdk.entity.ClassStudentData;
import com.eduhzy.ttw.commonsdk.entity.ClassTeacherData;
import com.eduhzy.ttw.commonsdk.entity.CommonData;
import com.eduhzy.ttw.commonsdk.entity.CourseCommentData;
import com.eduhzy.ttw.commonsdk.entity.CourseListData;
import com.eduhzy.ttw.commonsdk.entity.CourseLiveHomeData;
import com.eduhzy.ttw.commonsdk.entity.DiscoverData;
import com.eduhzy.ttw.commonsdk.entity.EntriesData;
import com.eduhzy.ttw.commonsdk.entity.EntriesDetailData;
import com.eduhzy.ttw.commonsdk.entity.LatestMsg;
import com.eduhzy.ttw.commonsdk.entity.LoginData;
import com.eduhzy.ttw.commonsdk.entity.MessageCode;
import com.eduhzy.ttw.commonsdk.entity.MineClassData;
import com.eduhzy.ttw.commonsdk.entity.MineInfo;
import com.eduhzy.ttw.commonsdk.entity.MyCourseData;
import com.eduhzy.ttw.commonsdk.entity.MyWorksData;
import com.eduhzy.ttw.commonsdk.entity.NoticeDetailData;
import com.eduhzy.ttw.commonsdk.entity.OrderPayStatus;
import com.eduhzy.ttw.commonsdk.entity.PlatformNoticeData;
import com.eduhzy.ttw.commonsdk.entity.RatingDetailData;
import com.eduhzy.ttw.commonsdk.entity.RatingHomeData;
import com.eduhzy.ttw.commonsdk.entity.RegisterData;
import com.eduhzy.ttw.commonsdk.entity.RegisterRequestData;
import com.eduhzy.ttw.commonsdk.entity.RightOrderInfo;
import com.eduhzy.ttw.commonsdk.entity.SaveWorksData;
import com.eduhzy.ttw.commonsdk.entity.SchoolTypeData;
import com.eduhzy.ttw.commonsdk.entity.SignUp1ParentData;
import com.eduhzy.ttw.commonsdk.entity.SignUp2Data;
import com.eduhzy.ttw.commonsdk.entity.UploadData;
import com.eduhzy.ttw.commonsdk.entity.VerifyMessageData;
import com.eduhzy.ttw.commonsdk.entity.WXPayData;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Url;

import static me.jessyan.retrofiturlmanager.RetrofitUrlManager.DOMAIN_NAME_HEADER;

/**
 * ================================================
 * CommonSDK 的 CommonApi 可以定义公用的关于 API 的相关常量, 比如说请求地址, 错误码等, 每个组件的 CommonApi 可以定义组件自己的私有常量
 * <p>
 * Created by JessYan on 30/03/2018 17:16
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * ================================================
 */
public interface CommonApi {
    //绑定用户不存在
    int NETWORK_ERROR_NOT_USER = 1100404;
    //暂无班级
    int ERROR_NOT_CLASS = 1105404;

    /**
     * 内网
     */
//    String APP_UPLOAD_DOMAIN = "http://preview.eduhzy.net:1560/preview/";//内网
//    String APP_DOMAIN = "http://192.168.0.130:8081";
    
    /**
     * 外网
     */
    String APP_DOMAIN = "http://47.100.189.167:8082";
    String APP_UPLOAD_DOMAIN = "http://139.196.120.178:8089/preview/";
    String APP_UPLOAD_DOMAIN_NAME = "upload";
    String APP_UPDATE = "/dec/desc/store/checkUpdate.jspx";

    String APP_UPLOAD_PATH = "saveForm.jspx";
    //    String APP_AVATAR = "http://192.168.0.108:8289/base_house/base/getUserTempAvatar.jspx?id=";
    String APP_AVATAR = "http://base.tangt.cn/base/base/getUserTempAvatar.jspx?id=";

    /**
     * 登录
     *
     * @param params
     * @return
     */
    @POST("/dec/base/login/loginUnified.jspx")
    Observable<CommonData<LoginData>> getLoginData(@Body Map<String, Object> params);

    /**
     * 第三方登录
     *
     * @param map
     * @return
     */
    @POST("/dec/base/login/loginUnifiedByThird.jspx")
    Observable<CommonData<LoginData>> getThirdLoginData(@Body Map<String, Object> map);

    /**
     * 第三方登录
     *
     * @param map
     * @return
     */
    @POST("/dec/base/login/loginUnifiedByThird.jspx")
    Call<CommonData<LoginData>> getThirdLoginDataByCall(@Body Map<String, Object> map);

    /**
     * 登录
     *
     * @param params
     * @return
     */
    @POST("/dec/base/login/loginUnified.jspx")
    Call<CommonData<LoginData>> getLoginDataByCall(@Body Map<String, Object> params);

    /**
     * 获取手机验证码
     *
     * @param params
     * @return
     */
    @POST("/dec/base/sms/sendValidateCode.jspx")
    Observable<CommonData<MessageCode>> getPhoneCode(@Body Map<String, Object> params);


    /**
     * 注册
     *
     * @param data
     * @return
     */
    @POST("/dec/base/user/saveUser.jspx")
    Observable<CommonData<RegisterData>> getRegisterData(@Body RegisterRequestData data);

    /**
     * 通过手机号码更新密码
     *
     * @param map
     * @return
     */
    @POST("/dec/base/user/upPassWordByMobile.jspx")
    Observable<CommonData<RegisterData>> requestResetPWD(@Body Map<String, Object> map);

    @POST("/dec/base/user/getUserInfo.jspx")
    Observable<CommonData<MineInfo>> getUserInfo(@Body Map<String, Object> map);

    @POST("/dec/base/login/thirdFirstLogin.jspx")
    Observable<CommonData<RegisterData>> getThirdRegisterData(@Body RegisterRequestData data);

    @Headers({DOMAIN_NAME_HEADER + APP_UPLOAD_DOMAIN_NAME})
    @POST("saveForm.jspx")
    Observable<CommonData<UploadData>> upload(@Body MultipartBody answerFile);

    @POST
    Observable<CommonData<UploadData>> upload(@Url String url, @Body MultipartBody answerFile);

    @POST("/dec/base/user/updateUserTempAvatar.jspx")
    Observable<CommonData<Map>> updateUserTempAvatar(@Body Map<String, Object> map);

    @POST("/dec/base/user/updateByPassword.jspx")
    Observable<CommonData<Map>> updateByPassword(@Body Map<String, Object> map);

    @POST("/dec/base/class/getClassByUser.jspx")
    Observable<CommonData<List<MineClassData>>> getClassByUser(@Body Map<String, Object> map);

    @POST("/dec/base/group/getZxxx02ListByXxid.jspx")
    Observable<CommonData<List<ChooseClassData>>> getZxxx02ListByXxid(@Body Map<String, Object> map);

    @POST("/dec/base/class/saveClassAndReturnData.jspx")
    Observable<CommonData<ClassDetailsData>> saveClassAndReturnData(@Body Map<String, Object> map);

    @POST("/dec/base/user/updateUser.jspx")
    Observable<CommonData<Map>> updateUser(@Body Map<String, Object> map);

    @POST("/dec/base/class/getClassInfoById.jspx")
    Observable<CommonData<ClassDetailsData>> getClassInfoById(@Body Map<String, Object> map);

    @POST("/dec/base/class/getTeacherByClass.jspx")
    Observable<CommonData<List<ClassTeacherData>>> getTeacherByClass(@Body Map<String, Object> map);

    @POST("/dec/base/class/deleteMemberByManager.jspx")
    Observable<CommonData<Map>> deleteMemberByManager(@Body Map<String, Object> map);

    @POST("/dec/base/class/getSubject.jspx")
    Observable<CommonData<ChooseSubjectData[]>> getSubject(@Body Map<String, Object> map);

    @POST("/dec/base/class/updateTeaSubject.jspx")
    Observable<CommonData<Map>> updateTeaSubject(@Body Map<String, Object> map);

    @POST("/dec/base/class/dropClass.jspx")
    Observable<CommonData<Map>> dropClass(@Body Map<String, Object> map);

    @POST("/dec/base/class/switchClassManager.jspx")
    Observable<CommonData<Map>> switchClassManager(@Body Map<String, Object> map);

    @POST("/dec/base/class/getUserByBjid.jspx")
    Observable<CommonData<List<ClassStudentData>>> getUserByBjid(@Body Map<String, Object> map);

    @POST("/dec/base/class/deleteClass.jspx")
    Observable<CommonData<Map>> deleteClass(@Body Map<String, Object> map);

    @POST("/dec/base/user/getTargetByQrCode.jspx")
    Observable<CommonData<ClassDetailsData>> getTargetByQrCode(@Body Map<String, Object> map);

    @POST("/dec/base/class/applyClass.jspx")
    Observable<CommonData<Map>> applyClass(@Body Map<String, Object> map);

    @POST("/dec/base/user/savePersonGroup.jspx")
    Observable<CommonData<Map>> savePersonGroup(@Body Map<String, Object> map);

    @POST("/dec/base/group/getBaseCodeByType.jspx")
    Observable<CommonData<List<SchoolTypeData>>> getBaseCodeByType(@Body Map<String, Object> map);

    @POST("/dec/base/group/saveGroupApply.jspx")
    Observable<CommonData<Map>> saveGroupApply(@Body Map<String, Object> map);

    @POST("/dec/base/user/updateContactByUser.jspx")
    Observable<CommonData<Map>> updateContactByUser(@Body Map<String, Object> map);

    /**
     * 二维码添加好友
     *
     * @param map
     * @return
     */
    @POST("/dec/base/user/getTargetByQrCode.jspx")
    Observable<CommonData<MineInfo>> getTargetByQrCode2(@Body Map<String, Object> map);

    @POST("/dec/base/class/applyClassList.jspx")
    Observable<CommonData<List<VerifyMessageData>>> applyClassList(@Body Map<String, Object> map);

    @POST("/dec/base/class/joinedClassByManager.jspx")
    Observable<CommonData<Map>> joinedClassByManager(@Body Map<String, Object> map);

    @POST("/dec/personal/message/deleteInboxMsg.jspx")
    Observable<CommonData<Map>> delApplyClass(@Body Map<String, Object> map);

    @POST("/dec/collection/research/getResearchList.jspx")
    Observable<CommonData<List<RatingHomeData>>> getResearchList(@Body Map<String, Object> map);

    @POST("/dec/collection/research/getResearchById.jspx")
    Observable<CommonData<RatingDetailData>> getResearchById(@Body Map<String, Object> map);

    @POST("/dec/collection/works/getWorksByResearchId.jspx")
    Observable<CommonData<List<EntriesData>>> getWorksByResearchId(@Body Map<String, Object> map);

    @POST("/dec/collection/works/getWorksById.jspx")
    Observable<CommonData<EntriesDetailData>> getWorksById(@Body Map<String, Object> map);

    @POST("/dec/collection/works/saveVote.jspx")
    Observable<CommonData<Map>> saveVote(@Body Map<String, Object> map);

    @POST("/dec/collection/works/saveWorks.jspx")
    Observable<CommonData<SignUp2Data>> saveWorks(@Body SaveWorksData saveData);

    @POST("/dec/collection/works/getClassify.jspx")
    Observable<CommonData<List<SignUp1ParentData>>> getClassify(@Body Map<String, Object> map);

    @POST("/dec/collection/works/getAwardWorksByResearchId.jspx")
    Observable<CommonData<List<EntriesData>>> getAwardWorksByResearchId(@Body Map<String, Object> map);

    @POST("/dec/res/res/showDirectList.jspx")
    Observable<CommonData<List<CourseLiveHomeData>>> showDirectList(@Body Map<String, Object> map);

    @POST("/dec/res/res/getCatalogById.jspx")
    Observable<CommonData<List<CourseListData>>> getCatalogById(@Body Map<String, Object> map);

    @POST("/dec/res/comment/commentPublish.jspx")
    Observable<CommonData<CourseCommentData>> commentPublish(@Body Map<String, Object> map);

    @POST("/dec/res/comment/getComment.jspx")
    Observable<CommonData<List<CourseCommentData>>> getComment(@Body Map<String, Object> map);

    @POST("/dec/res/shop/saveRightOrder.jspx")
    Observable<CommonData<List<RightOrderInfo>>> saveRightOrder(@Body Map<String, Object> map);

    @POST("/dec/pay/pay/getAliPayOrderInfo.jspx")
    Observable<CommonData<AliOrderData>> alipay(@Body Map<String, Object> map);

    @POST("/dec/trade/shopOrder/getShopOrderInfo.jspx")
    Observable<CommonData<List<RightOrderInfo>>> getShopOrderInfo(@Body Map<String, Object> map);

    @POST("/dec/res/res/getMyCourseList.jspx")
    Observable<CommonData<List<MyCourseData>>> getMyCourseList(@Body Map<String, Object> map);

    @POST("/dec/collection/works/getMyWorks.jspx")
    Observable<CommonData<List<MyWorksData>>> getMyWorks(@Body Map<String, Object> map);

    @POST("/dec/collection/works/saveFile.jspx")
    Observable<CommonData<Map>> saveFile(@Body Map<String, Object> map);

    @POST("/dec/portal/content/getContentList.jspx")
    Observable<CommonData<List<DiscoverData>>> getContentList(@Body Map<String, Object> map);

    @POST("/dec/pay/pay/getWxPayOrderInfo.jspx")
    Observable<CommonData<WXPayData>> getWxPayOrderInfo(@Body Map<String, Object> map);

    @POST("/dec/base/class/updateClassInfo.jspx")
    Observable<CommonData<Map>> updateClassInfo(@Body Map<String, Object> map);

    @POST("/dec/trade/order/orderPaid.jspx")
    Observable<CommonData<Map>> orderPaid(@Body Map<String, Object> map);

    @POST("/dec/trade/order/getOrderInfoById.jspx")
    Observable<CommonData<OrderPayStatus>> getOrderPayStatus(@Body Map<String, Object> map);

    @POST("/dec/personal/message/getInboxMsgList.jspx")
    Observable<CommonData<List<PlatformNoticeData>>> getSendMsgList(@Body Map<String, Object> map);

    @POST("/dec/personal/message/getMsgContent.jspx")
    Observable<CommonData<NoticeDetailData>> getMsgContent(@Body Map<String, Object> map);

    @POST("/dec/personal/message/markRead.jspx")
    Observable<CommonData<Map>> markRead(@Body Map<String, Object> map);

    @POST("/dec/personal/message/getLatestMsg.jspx")
    Observable<CommonData<LatestMsg>> getLateMsg(@Body Map<String,Object> map);
}
